<%--
  Created by IntelliJ IDEA.
  User: YIJIE
  Date: 2016/10/22
  Time: 19:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../inc/top.jsp"%>
<style>
    #comment{
        resize: none;
        width: 100%;
    }
    #reply{
        resize: none;
        width: 100%;
    }
    #replyArea{
        margin-top: 20px;
    }
    #commentArea{
        margin-top: 10px;
    }
</style>
<h2 style="font-weight: bold;">评论回复</h2>
<label>${nickname}的评论内容：</label>
<div id="commentArea">
    <textarea id="comment" name="comment" rows="5" type="text" readonly>${text}</textarea>
    <input name="comment_id" id="comment_id" type="hidden" value="${commentId}" class="h1"/>
    <input name="content_id" id="content_id" type="hidden" value="${contentId}" class="h2"/>
    <input name="user_id" id="user_id" type="hidden" value="${sessionScope.admin.user_id}" class="h3"/>
</div>
<div id="replyArea">
    <label>请输入回复内容：</label>
    <textarea id="reply" name="reply" rows="10" type="text"></textarea>
</div>
<div>
    <button class="king-btn-demo king-btn king-border king-round king-success" id="sub">提交回复</button>
    <a class="king-btn-demo king-btn king-round king-default" id="cancel" href="${CONTEXTPATH}/admin/comment/manageComments.jsp">返回</a>
</div>
<script>
    $("#sub").click(function () {
        var commentId = $(this).parent().prevAll().find(".h1").attr("value");
        var contentId = $(this).parent().prevAll().find(".h2").attr("value");
        var userId = $(this).parent().prevAll().find(".h3").attr("value");
        var reply = document.getElementById('reply').value;
        var url = getContextPath()+"/CommentController/addReply.press";
        $.post(url, {"comment_id": commentId,"content_id":contentId,"user_id":userId,"comment_text":reply},function (result) {
            if (result.msg == "yes") {
                alert("回复成功！")
                window.location.href=getContextPath()+"/admin/comment/manageComments.jsp";
            } else {
                alert("回复失败，请重新回复！");
                window.location.reload();
            }
        }, "json")

    });
</script>
<%@include file="../inc/bottom.jsp"%>
